home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 05 Programming / BFEDIT.DOC < prev    next >
Text File  |  2019-04-13  |  4KB  |  85 lines

  1. This is in answer to the numerous users of Blazin' Forth who want a full screen editor, but who have had some trouble getting one up on their systems.
  2.  
  3. The approach used here requires altering LIST (screen #5), and adding a few lines of code to screen #41. Please note: You must have the source code do make these changes.
  4.  
  5. The changes to LIST are indicated below. The only changes are the addition of DECIMAL in line 9 , and the addition of 2 .R ." > " in line 11. This will cause the screens to list in the format shown below, with line numbers as 0> instead of just a number.
  6.  
  7. scr #5 
  8.  0> ( utilities -- [line] .line list                      sdbjun85)
  9.  1> 
  10.  2> vocabulary editor
  11.  3> 
  12.  4> : (line)   printing? @ if cmdoff then block swap
  13.  5>            c/l * + c/l printing? @ if #lp (cmdout) drop then ;
  14.  6> 
  15.  7> : .line   (line) -trailing type ;
  16.  8> 
  17.  9> : list   decimal cr  dup  scr  !
  18. 10>    ." scr #" u.   16  0
  19. 11>    do   cr  i 2 .r ." > " i  scr @
  20. 12>          .line  ?terminal ?leave
  21. 13>    loop   cr editor ;
  22. 14> 
  23. 15> 
  24.  
  25. The actual screen editing functions are shown below. You will need to add PL (for Put Line) , SLINE (Screen Line) and the words 0> 1> etc. created by SLINE to this screen. PL simply accepts a line of input from the terminal, and moves it to the insert buffer and to the appropriate spot in the appropriate buffer. SLINE is used to define the numbers displayed by LIST as actual forth words, which call PL with the proper line number.
  26.  
  27. scr #41 
  28.  0> ( starting forth editor -- r p                        sdbmay85)
  29.  1> 
  30.  2> : (r)     >line# ibuf 1+ swap >move ;
  31.  3> 
  32.  4> : p   5e  text ibuf bufmove (r) ;
  33.  5> 
  34.  6> // following words add fullscreen editing.
  35.  7> : pl  c/l * r# ! 0 text pad c@ 0= if ibuf 55 blank then
  36.  8>       ibuf bufmove (r) quit ;
  37.  9> : sline   create c, does> c@ pl ;
  38. 10> 
  39. 11>  0 sline  0>  1 sline  1>  2 sline  2>  3 sline 3>
  40. 12>  4 sline  4>  5 sline  5>  6 sline  6>  7 sline 7>
  41. 13>  8 sline  8>  9 sline  9> 0a sline 10> 0b sline 11>
  42. 14> 0c sline 12> 0d sline 13> 0e sline 14> 0f sline 15>
  43. 15> 
  44.  
  45.  
  46. Once you have correctly entered these changes and FLUSHed the buffers, proceed as follows:
  47.  
  48. FORGET THRU
  49. 1 LOAD
  50.  
  51. This will cause the system to recompile, you will get a few "XXXX already exists" messages. This is normal.
  52.  
  53. When you get the message "LOCATE ENABLED" the system is recompiled, and the fullscreen editing extensions have been added.
  54.  
  55. Now do:
  56.  
  57. DCLOSE
  58.  
  59. Remove the systems disk, and insert a formatted *program* disk into the drive.
  60.  
  61. Now type                                
  62. SAVE-FORTH
  63.  
  64. you will be prompted for a filename. Give it a unique filename (SAVE-FORTH won't replace any files, unless you are daring, and give it the @0: or @1: prefix.) This will cause the modified forth to be saved to disk.
  65.  
  66.  
  67. Using the Editor:
  68.  
  69. All the old editor commands are still active, in addition, you may now cursor around the screen at will, inserting and deleting as you like. Only two things should be remembered:
  70.  
  71. 1) The line numbers 0> , 1> etc. are now defined as Forth words, and so you must remember to follow each with at least one space. For Example:
  72.  
  73. 0> // this is line 0
  74.  
  75. not
  76.  
  77. 0>//this is line 0
  78.  
  79. The character length of each line is still only 64 characters in length. If you type more than that, the line will be truncated. Such is life. You can always LIST the screen (or type the line using XX T ) to check up on things.
  80.  
  81. I hope this answers the questions on exactly how to do it, and also points out the flexibility and extensibility of Forth. How many other languages let you add fullscreen editing or other features? How many let you do it in less than 15 lines of code?
  82.  
  83. Goodluck!
  84. SDB
  85.